home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form AppPrinting
- Caption = "AppName"
- ClientHeight = 1635
- ClientLeft = 3420
- ClientTop = 3465
- ClientWidth = 3615
- Height = 2040
- Left = 3360
- LinkMode = 1 'Source
- LinkTopic = "Form1"
- ScaleHeight = 1635
- ScaleWidth = 3615
- Top = 3120
- Width = 3735
- Begin Timer StartPrintTimer
- Enabled = 0 'False
- Interval = 3
- Left = 3000
- Top = 1140
- End
- Begin CommandButton CancelCmd
- Caption = "Cancel"
- Height = 375
- Left = 1080
- TabIndex = 0
- Top = 1080
- Width = 1335
- End
- Begin Label DocumentLbl
- Alignment = 2 'Center
- Height = 555
- Left = 180
- TabIndex = 2
- Top = 480
- Width = 3315
- End
- Begin Label PrintingLbl
- Alignment = 2 'Center
- Caption = "Printing"
- Height = 255
- Left = 240
- TabIndex = 1
- Top = 180
- Width = 3195
- End
- Sub CancelCmd_Click ()
- App_PrintCancel = True
- Beep
- End Sub
- Sub Form_Load ()
- AppPrinting.Caption = APP_NAME
- Remove_Items_From_SysMenu AppPrinting
- Place_DialogBox_in_Form AppPrinting, AppMain
- DocumentLbl.Caption = UCase$(App_FileName)
- App_PrintCancel = False
- Screen.MousePointer = NORMAL
- StartPrintTimer.Enabled = True
- End Sub
- Sub PrintData ()
- ' This routine will print a file to the DEFAULT printer. The dialog is
- ' modal but still allowing the user to CANCEL the print. The routine
- ' uses VB functions to determine page size for page breaks. A fudge of
- ' one less line is used to protect for VB errors with LaserJet III's.
- Dim PrintLine As String
- Dim HeaderLine As String
- Dim PageSize As Integer
- Dim LineSpace As Integer
- Dim LinesPerPage As Integer
- Dim CurrentLine As Integer
- Dim IndexStart As Integer
- Dim IndexEnd As Integer
- DocumentLbl.Caption = UCase$(App_FileName) + CRLF + "Copy" + Str$(App_PrintCopyNumber)
- AppPrinting.Refresh
- Screen.MousePointer = NORMAL
- On Error GoTo PrintDataError
- ' Determine the available space on the printer page
- LineSpace = Printer.TextHeight("M")
- PageSize = Printer.ScaleHeight
- LinesPerPage = (PageSize / LineSpace) - 1 ' -1 is fudge
- HeaderLine = "Page: "
- CurrentLine = 3
- AppPrinting.PrintingLbl.Caption = "Printing Page : 1"
- AppPrinting.Refresh
- Printer.Print HeaderLine + "1" + CRLF
- IndexStart = 1
- IndexEnd = InStr(IndexStart, App_Data, CRLF)
- Do While IndexEnd <> 0 And DoEvents()
- '
- ' Allow the user to cancel the print
- '
- rc% = SetActiveWindow(AppPrinting.hdc)
- PrintLine = Mid$(App_Data, IndexStart, IndexEnd - IndexStart)
- Printer.Print PrintLine
- CurrentLine = CurrentLine + 1
- If CurrentLine > LinesPerPage Then
- CurrentLine = 3
- If App_PrintCancel = True Then
- AppPrinting.PrintingLbl.Caption = "Printing has been cancelled."
- AppPrinting.Refresh
- pause (5)
- Exit Do
- Else
- Printer.NewPage
- AppPrinting.PrintingLbl.Caption = "Printing Page : " + Str$(Printer.Page)
- AppPrinting.Refresh
- Printer.Print HeaderLine + LTrim$(Str$(Printer.Page)) + CRLF
- End If
- End If
- IndexStart = IndexEnd + 2
- IndexEnd = InStr(IndexStart, App_Data, CRLF)
- Loop
- Printer.NewPage
- Printer.EndDoc
- ExitPrintData:
- On Error GoTo 0
- Exit Sub
- PrintDataError:
- a$ = "Cannot print;" + CRLF + CRLF + "check to ensure the printer is installed correctly and your disk has sufficient available space."
- MsgBox a$, MB_ICONEXCLAMATION, APP_NAME
- On Error GoTo 0
- Exit Sub
- End Sub
- Sub StartPrintTimer_Timer ()
- StartPrintTimer.Enabled = False
- pause (3)
- PrintData
- Unload AppPrinting
- End Sub
-